package com.itheima.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/*
TCP  服务端
 */
public class ServerDemo {

    public static void main(String[] args) throws IOException {
        //创建对象
        ServerSocket ss = new ServerSocket(10086);
        //先建立连接 获取 socket
        Socket accept = ss.accept();
        //接收数据
        InputStream is = accept.getInputStream();
        //打印数据
        int b;
        while ((b=is.read())!=-1){
            System.out.println((char)b);
        }
        //释放资源
        ss.close();


    }

}
